package WebModule::Train;

use strict;

use base qw(WebModule);

__PACKAGE__->meta->setup(
    table   => 'train',

    columns => [
        id            => { type => 'serial', not_null => 1 },
        train_number  => { type => 'varchar', length => 35, not_null => 1 },
        begin_station => { type => 'integer', not_null => 1 },
        end_station   => { type => 'integer', not_null => 1 },
        train_type    => { type => 'varchar', length => 80, not_null => 1 },
        begin_time    => { type => 'time', default => '00:00:00', not_null => 1, precision => 6, scale => 6 },
        end_time      => { type => 'time', default => '00:00:00', not_null => 1, precision => 6, scale => 6 },
        cost_time     => { type => 'varchar', length => 45, not_null => 1 },
        course        => { type => 'varchar', length => 45, not_null => 1 },
        price         => { type => 'varchar', length => 249, not_null => 1 },
    ],

    primary_key_columns => [ 'id' ],

    unique_key => [ 'train_number', 'begin_station', 'end_station' ],

    foreign_keys=>
    [
        b_station=>{
            class=>'WebModule::Station',
            key_columns=>{ begin_station=>'id' },
        },
        e_station=>{
            class=>'WebModule::Station',
            key_columns=>{ end_station=>'id' },
        },
    ],

);

1;

